<!-- 求职者学历情况-招聘者 -->
<template>
  <div class="Direct" ref="Direct_chart">
  </div>
</template>
<script lang='ts'>
import { reactive, ref, onMounted, onBeforeMount, getCurrentInstance } from 'vue'
import { useStore } from 'vuex'
import * as echarts from 'echarts';
// import { EChartOption, EChartsResponsiveOption } from "echarts"
import { elmessage, data } from "@/hook/hook"
import {getJobSeekerEdu} from "@/api/enterpriseApi"
export default {
  name: 'JobSeekerEduChart',
  setup() {
    const store = useStore()
    // @ts-ignore
    const { proxy } = getCurrentInstance() // 1.获取proxy实例

    const Direct_chart = ref()


    // 从后台获取数据
    const getDatas = () => {
      getJobSeekerEdu(data()).then((res: any) => {

        dataSetX(res.data["dataX"])
        dataSetY(res.data["dataY"])
        

      })
    }
    const dataSetX = (data: any) => {
      // store.state.enterpriseState.jobSeekerJobEx.X=data
      store.state.enterpriseState.jobSeekerEdu.X=data
      
    }
    const dataSetY = (data: any) => {
      store.state.enterpriseState.jobSeekerEdu.Y=data
    }
    const dataGetX = () => {
      return store.state.enterpriseState.jobSeekerEdu.X
    }
    const dataGetY = () => {
      return store.state.enterpriseState.jobSeekerEdu.Y
    }
    // 画图
    const init = () => {
      var myChart = echarts.init(Direct_chart.value) //这里是为了获得容器所在位置   

      // 指定地图配置项和数据-柱状
      var option = {
        title: {
          text: '求职者学历分布',
          // subtext: '注：仅统计前十',
          left: 'left',
          textStyle:{
            fontSize: 24
          }
        },
        xAxis: {
          type: 'category',
          data: dataGetX()
        },
        yAxis: {
          type: 'value'
        },
        series: [
          {
            data:dataGetY(),
            type: 'bar',
            showBackground: true,
            backgroundStyle: {
              color: 'rgba(180, 180, 180, 0.2)'
            }
          }
        ]
      };


      myChart.setOption(option)


    }

    onMounted(async () => {
      await getDatas()
      setTimeout(() => {
        init()
      }, 500);

    })


    return {
      Direct_chart,
    }
  }
}
</script>
<style scoped>
.Direct {
  /* display: flex; */
  width: 600px;
  height: 500px;
}
</style>

